import axios from "axios";
import {constants} from "./index";
import {fromJS} from "immutable";

export const logout = () => ({
    type:constants.LOGOUT,
    value: fromJS(false)
});


export const changeLogin = () => ({
    type: constants.CHANGE_LOGIN,
    value: fromJS(true)

})
export const login = (account, password) => {
    return (dispatch) => {
        axios.get('http://localhost:3000/login?account=' + account + '&password=' + password).then((res) => {
            const result = res.data.data;
            if (result) {
                dispatch(changeLogin());
            } else {
                alert('登录失败');
            }
        })
    };
}
